﻿<Window x:Class="LocTranslate.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:LocTranslate"
    xmlns:ltl="clr-namespace:LocTranslate;assembly=LocTranslateLibrary"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras"
    Title="LocTranslate" Width="800" Height="600" ResizeMode="CanResize"
    FontFamily="Verdana" FontSize="11" Icon="/LocTranslate;component/LocTranslate.ico" WindowState="Maximized">
    
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Closing">
            <cmd:EventToCommand
                Command="{Binding CmdClosing}"
                PassEventArgsToCommand="True" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
    
    <Window.Resources>
        <Style TargetType="Image">
            <Setter Property="Width" Value="16" />
            <Setter Property="Height" Value="16" />
        </Style>
    </Window.Resources>
    
    <DockPanel LastChildFill="True">
        <Grid DockPanel.Dock="Top">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>

            <TextBlock Margin="5" Grid.ColumnSpan="3" 
                       Text="{ltl:Translate loc_startInfo}" VerticalAlignment="Center" />

            <TextBlock Grid.Row="1" Margin="5,0" Text="{ltl:Translate loc_originalFile}" VerticalAlignment="Center" />
            <TextBox Grid.Row="1" Grid.Column="1" Height="20" Text="{Binding OriginalFile.FileFullName}" 
                     VerticalContentAlignment="Center" VerticalAlignment="Center" />
            <Button Grid.Row="1" Grid.Column="2" Margin="5,2,5,2" Command="{Binding CmdOpenOriginalFile}">
                <Image Source="..\images\folder_yellow_open.png" />
            </Button>

            <StackPanel Grid.Row="2" Grid.Column="1" Orientation="Horizontal">
                <StackPanel.Style>
                    <Style TargetType="StackPanel">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding OriginalFile}" Value="{x:Null}">
                                <Setter Property="Visibility" Value="Hidden" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </StackPanel.Style>
                <TextBlock Margin="5,0,2,0" Text="{ltl:Translate loc_fileName}" />
                <TextBlock Text="{Binding OriginalFile.FileName}" FontWeight="Bold" />
                <TextBlock Margin="10,0,2,0" Text="{ltl:Translate loc_targetProject}" />
                <TextBlock Text="{Binding OriginalFile.TargetProject}" FontWeight="Bold" />
                <TextBlock Margin="10,0,2,0" Text="{ltl:Translate loc_targetProjectVersion}" />
                <TextBlock Text="{Binding OriginalFile.TargetProjectVersion}" FontWeight="Bold" />
            </StackPanel>

            <TextBlock Grid.Row="3" Grid.Column="0" Margin="5,0" Text="{ltl:Translate loc_localizedFile}" VerticalAlignment="Center" />
            <TextBox Grid.Row="3" Grid.Column="1" Height="20" Text="{Binding LocalizedFile.FileFullName}"
                     VerticalContentAlignment="Center" VerticalAlignment="Center" />
            <Button Grid.Row="3" Grid.Column="2" Margin="5,2,5,2" DockPanel.Dock="Right" Command="{Binding CmdOpenLocalizedFile}">
                <Image Source="..\images\folder_yellow_open.png" Width="16" Height="16" />
            </Button>

            <StackPanel Grid.Row="4" Grid.Column="1" Orientation="Horizontal">
                <StackPanel.Style>
                    <Style TargetType="StackPanel">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding LocalizedFile}" Value="{x:Null}">
                                <Setter Property="Visibility" Value="Hidden" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </StackPanel.Style>
                <TextBlock Margin="5,0,2,0" Text="{ltl:Translate loc_fileName}" />
                <TextBlock Text="{Binding LocalizedFile.FileName}" FontWeight="Bold" />
                <TextBlock Margin="10,0,2,0" Text="{ltl:Translate loc_targetProject}" />
                <TextBlock Text="{Binding LocalizedFile.TargetProject}" FontWeight="Bold" />
                <TextBlock Margin="10,0,2,0" Text="{ltl:Translate loc_targetProjectVersion}" />
                <TextBlock Text="{Binding LocalizedFile.TargetProjectVersion}" FontWeight="Bold" />
                <TextBlock Margin="25,0,2,0" Text="{ltl:Translate loc_willUpdate}" />
                <TextBlock Text="{Binding OriginalFile.TargetProject}" FontWeight="Bold" />
                <Separator Width="1" Opacity="0" />
                <TextBlock Text="{Binding OriginalFile.TargetProjectVersion}" FontWeight="Bold" />
            </StackPanel>

        </Grid>

        <Border DockPanel.Dock="Top" Margin="5,5,5,0" Padding="5"
                BorderBrush="DarkGray" BorderThickness="1" CornerRadius="5" Background="LightYellow">
            <Border.Style>
                <Style TargetType="Border">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding ShowWarning}" Value="False">
                            <Setter Property="Visibility" Value="Collapsed" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </Border.Style>
            <StackPanel Orientation="Horizontal">
                <Image Source="..\images\messagebox_warning.png" />
                <Separator Width="10" Opacity="0" />
                <TextBlock Text="{ltl:Translate loc_warning}" />
            </StackPanel>
        </Border>

        <Expander DockPanel.Dock="Top" Margin="5" IsEnabled="{Binding OriginalFile.HasInfo}" IsExpanded="True">
            <Expander.Header>
                <StackPanel Orientation="Horizontal" Margin="5,0">
                    <Button Margin="2" Command="{Binding CmdRefreshItems}">
                        <Image Source="..\images\reload.png" />
                    </Button>
                    <Separator Width="4" />
                    <Button Margin="2" Command="{Binding CmdSave}">
                        <Image Source="..\images\filesave.png" />
                    </Button>
                    <Separator Width="30" Opacity="0" />
                    <Image Source="..\images\ledgreen.png" />
                    <TextBlock VerticalAlignment="Center" Text="{ltl:Translate loc_localized}" />
                    <Separator Width="15" Opacity="0" />
                    <Image Source="..\images\ledred.png" />
                    <TextBlock VerticalAlignment="Center" Text="{ltl:Translate loc_notLocalized}" />
                    <Separator Width="15" Opacity="0" />
                    <Image Source="..\images\ledorange.png" />
                    <TextBlock VerticalAlignment="Center" Text="{ltl:Translate loc_deprecated}" />
                </StackPanel>
            </Expander.Header>
            <Border BorderBrush="SteelBlue" BorderThickness="1" CornerRadius="5" Padding="5">
                <TextBlock Text="{Binding OriginalFile.Info}" />
            </Border>
        </Expander>

        <StatusBar DockPanel.Dock="Bottom">
            <StatusBarItem>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Margin="0,0,5,0" Text="{ltl:Translate loc_appIcon}" />
                    <TextBlock>
                    <Hyperlink NavigateUri="http://pattedemouche.free.fr/" RequestNavigate="Hyperlink_RequestNavigate">Charlotte Schmidt</Hyperlink>
                    </TextBlock>
                </StackPanel>
            </StatusBarItem>
            <Separator />
            <StatusBarItem>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Margin="0,0,5,0" Text="{ltl:Translate loc_images}" />
                    <TextBlock>
                    <Hyperlink NavigateUri="http://www.icon-king.com" RequestNavigate="Hyperlink_RequestNavigate">Nuvola icon set by David Vignoni</Hyperlink>
                    </TextBlock>
                </StackPanel>
            </StatusBarItem>
            <Separator />
            <StatusBarItem>
                <StackPanel Orientation="Horizontal">
                    <Button Command="{Binding CmdAbout}" Cursor="Hand">
                        <Button.Template>
                            <ControlTemplate>
                                <Border Background="Transparent" BorderBrush="Transparent">
                                    <ContentPresenter Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content}" />
                                </Border>
                            </ControlTemplate>
                        </Button.Template>
                        <TextBlock Foreground="Blue" Text="{ltl:Translate loc_about}" />
                    </Button>
                </StackPanel>
            </StatusBarItem>
            
            <StatusBarItem HorizontalContentAlignment="Right">
                <StackPanel Orientation="Horizontal">
                    <TextBlock Margin="0,0,5,0" Text="ver: 1.0" />
                </StackPanel>
            </StatusBarItem>
        </StatusBar>
        
        
        <ListView ItemsSource="{Binding LocItems}" HorizontalContentAlignment="Stretch"
                  ScrollViewer.CanContentScroll="False"
                  FocusManager.IsFocusScope="True"
                  KeyboardNavigation.TabNavigation="Continue">
            <ListView.Resources>
                <Style TargetType="TextBox">
                    <Setter Property="AcceptsReturn" Value="True" />
                    <Setter Property="TextWrapping" Value="Wrap" />
                    <Setter Property="VerticalScrollBarVisibility" Value="Auto" />
                </Style>
                
                <Style TargetType="Image" x:Key="img">
                    <Setter Property="Width" Value="16" />
                    <Setter Property="Height" Value="16" />
                    <Setter Property="Margin" Value="0" />
                </Style>
            </ListView.Resources>
            
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                    <Setter Property="VerticalContentAlignment" Value="Stretch" />
                    <Setter Property="IsTabStop" Value="False" />
                </Style>
            </ListView.ItemContainerStyle>
            
            <ListView.View>
                <GridView>
                    <GridViewColumn Header="{ltl:Translate loc_key}" Width="Auto">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Key}" />
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>

                    <GridViewColumn Header="{ltl:Translate loc_originalValue}" Width="200">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBox Text="{Binding OriginalValue}" IsTabStop="False" />
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>

                    <GridViewColumn Header="{ltl:Translate loc_localizedValue}" Width="200">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBox Text="{Binding Path=LocalizedValue, UpdateSourceTrigger=PropertyChanged}" />
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>

                    <GridViewColumn Header="{ltl:Translate loc_comment}" Width="200">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Comment}" />
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>

                    <GridViewColumn Header="{ltl:Translate loc_ledLocalized}" Width="30" >
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <Image Style="{StaticResource img}" Source="..\images\ledgreen.png" Name="imgLocalized" />   
                                
                                <DataTemplate.Triggers>
                                    <DataTrigger Binding="{Binding LocalizedValue}" Value="">
                                        <Setter TargetName="imgLocalized" Property="Source" Value="..\images\ledred.png" />
                                    </DataTrigger>
                                </DataTemplate.Triggers>
                                
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>

                    <GridViewColumn Header="{ltl:Translate loc_ledDeprecated}" Width="30" >
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <Image Style="{StaticResource img}" Source="..\images\ledgreen.png" Name="imgDeprecated" />
                                
                                <DataTemplate.Triggers>
                                    <DataTrigger Binding="{Binding Deprecated}" Value="true">
                                        <Setter TargetName="imgDeprecated" Property="Source" Value="..\images\ledorange.png" />
                                    </DataTrigger>
                                </DataTemplate.Triggers>

                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    
                </GridView>
            </ListView.View>
            
        </ListView>
    </DockPanel>
</Window>
